package com.wenhai.spring.aop.features.aspect;

import org.aspectj.lang.ProceedingJoinPoint;

import java.util.Random;

/**
 *
 *
 * @author wenhai
 * @date   2021/4/28
 */
public class AspectXmlConfiguration {

    public void beforeAnyPublicMethod() {
        System.out.println("beforeAnyPublicMethod any public method.");
    }
    public void afterAnyPublicMethod() {
        System.out.println("afterAnyPublicMethod any public method.");
    }
    public void afterThrowingAnyPublicMethod() {
        System.out.println("afterThrowingAnyPublicMethod any public method.");
    }
    public void afterReturningAnyPublicMethod() {
        System.out.println("afterReturningAnyPublicMethod any public method.");
    }

        public Object aroundAnyPublicMethod(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("@Around any public method：" + pjp.getSignature());
        if (new Random().nextBoolean()) {
            throw new RuntimeException("For Purpose from XML configuration");
        }
        return pjp.proceed();
    }

}
